package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.T100WcStta;
import com.ruoyi.system.service.T100WcSttaService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

@Controller
@RequestMapping("/system/stta")
public class T100WcSttaController extends BaseController {


    private String prefix = "system/stta";

    @Autowired
    private T100WcSttaService sysWCSttaTService;

    @RequiresPermissions("system:stta:view")
    @GetMapping()
    public String stta()
    {
        return prefix + "/stta";
    }

    /**
     * 查询列表
     */
    @RequiresPermissions("system:stta:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(T100WcStta t100WcStta)
    {
        startPage();
        List<T100WcStta> list = sysWCSttaTService.selectSttaList(t100WcStta);
/*        for (T100WcStta stta : list) {
            System.out.println(stta.toString());
        }*/
        return getDataTable(list);
    }


    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    @RequiresPermissions("system:stta:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(T100WcStta t100WcStta)
    {
        return toAjax(sysWCSttaTService.insertStta(t100WcStta));
    }


    @RequiresPermissions("system:stta:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        T100WcStta stta = sysWCSttaTService.selectSttaById(id);
        mmap.put("stta", stta);
        return prefix + "/edit";
    }


    @RequiresPermissions("system:stta:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(T100WcStta t100WcStta)
    {
        return toAjax(sysWCSttaTService.updateStta(t100WcStta));
    }


    @RequiresPermissions("system:stta:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String[] ids)
    {
        return toAjax(sysWCSttaTService.deleteSttaByIds(ids));
    }
}
